var IS_AUTHENTICATED=void 0,Global=()=>{};Global.getURLParameter=(c,d)=>{for(var a=c.substring(c.indexOf("?")+1).split("&"),b=0;b<a.length;b++){var e=a[b].split("=");if(e[0]==d)return e[1]}};
Global.to_bookmarks=(c,d,a)=>{var b=$(c);$.ajax({url:"/api/favorite/",type:"POST",data:{obj:a,content_type:d},dataType:"json",success(a){a.result?b.find("[data-icon='favorite']").addClass("text-success"):b.find("[data-icon='favorite']").removeClass("text-success");b.find("[data-count='favorite']").text(a.count)}});return!1};
Global.like=(c,d,a)=>{var b=$(c),e=b.next();$.ajax({url:"/api/like/",type:"POST",data:{obj:a,content_type:d},dataType:"json",success(a){a.result?(b.find("[data-icon='like']").addClass("text-success"),e.find("[data-icon='dislike']").removeClass("text-success")):b.find("[data-icon='like']").removeClass("text-success");b.find("[data-count='like']").text(a.like_count);e.find("[data-count='dislike']").text(a.dislike_count)}});return!1};
Global.dislike=(c,d,a)=>{var b=$(c),e=b.prev();$.ajax({url:"/api/dislike/",type:"POST",data:{obj:a,content_type:d},dataType:"json",success(a){a.result?(b.find("[data-icon='dislike']").addClass("text-success"),e.find("[data-icon='like']").removeClass("text-success")):b.find("[data-icon='dislike']").removeClass("text-success");b.find("[data-count='dislike']").text(a.dislike_count);e.find("[data-count='like']").text(a.like_count)}});return!1};
Global.subscribe=(c,d,a)=>{var b=$(c);$.ajax({url:"/api/subscribe/",type:"POST",data:{obj:a,content_type:d},dataType:"json",success(a){b.prop("checked",a.result);b.parent().find(".badge").text(a.count)}});return!1};Global.read_notice=(c,d)=>{var a=$(c);$.ajax({url:"/api/notice/"+d+"/read/",type:"POST",data:{obj:d},success(b){Global.setItemCounter("notification_counter",b.unreaded_count);b.result&&a.removeClass("unreaded")}});return!0};
Global.nonlogin=()=>{Global.showDialog("authentication_required_dialog");return!1};Global.update=(c)=>{$(c).find("[title]").tooltip()};Global.setItemCounter=(c,d,a)=>{a=void 0===a?!1:a;jQuery("#"+c).find(".badge").each(function(){var b=jQuery(this);b.html(d);0!=d||a?(b.addClass("d-inline-block"),b.removeClass("d-none")):(b.addClass("d-none"),b.removeClass("d-inline-block"))})};
Global.init=(c,d)=>{d=void 0===d?"body":d;(IS_AUTHENTICATED=void 0===c?!1:c)&&setInterval(()=>{$.ajax({url:"/api/notice/check/",type:"POST",data:{check:!0},success(a){Global.setItemCounter("notification_counter",a.unreaded_count)}})},6E4);Global.update($(d));Global.showPrivacyPolicyDialog()};
Global.showDialog=(c,d,a)=>{var b=jQuery("#"+c);if(b.length){if(void 0!==d)b.on("hidden.bs.modal",d);void 0!==a&&b.find("#js-approve").bind("click",a);b.modal("show")}else jQuery.ajax({url:"/api/static/"+c+"/",type:"GET",dataType:"json",success(b){jQuery(b.dialog).appendTo(jQuery("body"));return Global.showDialog(c,d,a)}});return b};
Global.showPrivacyPolicyDialog=()=>{void 0===Cookies.get("accept_policy",{domain:"evileg.com"})&&Global.showDialog("privacy_policy_dialog",()=>{Cookies.set("accept_policy",{domain:"evileg.com"},{expires:365})})};
Global.share=(c,d)=>{Global.showDialog("share_dialog",(a)=>{jQuery("#share_dialog").remove()},(a)=>{a.preventDefault();a=new FormData(jQuery("#formShare").get(0));a.set("content_type",c);a.set("object_id",d);jQuery.ajax({url:"/api/static/share_dialog/",type:"POST",data:a,cache:!1,processData:!1,contentType:!1,success(a){jQuery('[data-type="'+c+'"][data-id="'+d+'"][data-count="shares"]').text(a.shares)}});return!0})};function toTop(){$("html, body").animate({scrollTop:0},"slow")}
window.onscroll=()=>{var c=$("#toTop");20<document.body.scrollTop||20<document.documentElement.scrollTop?c.fadeIn("slow"):c.fadeOut("slow")};
